//
//  AnimateViewController.m
//  RunLoopDemo
//
//  Created by jikuan zhang on 2021/7/7.
//  Copyright © 2021 hsgd. All rights reserved.
//

#import "AnimateViewController.h"


@interface AnimateViewController ()

@end

@implementation AnimateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    CAReplicatorLayer *layer = [CAReplicatorLayer layer];
    layer.frame = CGRectMake(50, 50, 200, 200);
    layer.backgroundColor = [UIColor lightGrayColor].CGColor;
    [self.view.layer addSublayer:layer];
    
    CALayer *bar = [CALayer layer];
    bar.backgroundColor = [UIColor redColor].CGColor;
    bar.bounds = CGRectMake(0, 0, 10, 100);
    bar.cornerRadius = 5;
    bar.masksToBounds = YES;
    bar.position = CGPointMake(15, 200);
    bar.anchorPoint = CGPointMake(0.5, 1);
    [layer addSublayer:bar];
    
    CABasicAnimation *anim = [CABasicAnimation animation];
    anim.keyPath = @"transform.scale.y";
    anim.toValue = @(0.1);
    anim.autoreverses = YES;
    anim.repeatCount = MAXFLOAT;
    anim.removedOnCompletion = NO;
    anim.duration = 1;
    [bar addAnimation:anim forKey:nil];
    
    layer.instanceCount = 10;
    layer.instanceTransform = CATransform3DMakeTranslation(20, 0, 0);
    // 设置复制子层的延迟动画时长
    layer.instanceDelay = 0.618;
    

}



@end
